<?php
class Application_Form_User extends Zend_Form
{
	public function __construct($options = null)
	{
		$this->setName('user');
		$this->setMethod("post");
		
		//the first name element
		$this->addElement("text","firstName", array(
				'label'			=> 'First Name:',
				'required'  	=> true,
				'filters'    	=> array('StringTrim','StripTags'),
				));
		//the last name element
		$this->addElement("text", "LastName", array(
				'label'			=> 'Last Name:',
				'required'		=> true,
				'filters'		=> array('StringTrim', 'StripTags'),
				));
		
		
		
		$sexCond = array('min' => 1, 'max' => 2);
		
		$sex = new  Zend_Form_Element_Select("sex");
		$sex 	->setLabel('I am:')
				->setRequired(true)
				->addMultiOptions( array(
	            				'0' => 'Select sex',
	                            '1' => 'Male',
	                            '2' => 'Female',
	                            ))
				->addValidator('NotEmpty')
				->addValidator(new Zend_Validate_Between($sexCond))
				->setAttribs(array(
	                                'id'=>'sex_id',
	                            ))
				->addErrorMessage('You need to select one value');
		$mobile = new Zend_Form_Element_Text('mobile');
		$mobile->setLabel('Mobile:')
		->setRequired(false)
		->setFilters(array('StringTrim','StripTags'));
		$this->addElements(array($sex,$mobile));
		/*/
		$this->addElement('select', 'sex', array(
	            'label'      => 'I am:',
	            'required'   => true,
	            'attribs'	 =>   array(
	                                'id'=>'sex_id',
	                            ),
	            'multioptions'   => array(
	            				'0' => 'Select sex',
	                            '1' => 'Male',
	                            '2' => 'Female',
	                            ),
				'validators'	 => array(new Zend_Validate_Between($options)),
				'ErrorMessage'   => 'You need to select one value'
        ));
		*/
		
		// Un bouton d'envoi
		$this->addElement('submit', 'submit', array(
				'ignore'   => true,
				'label'    => 'Register',
				'test'	   => 'registration'
		));
		
		$this->setDecorators( array( array('ViewScript', array('viewScript' => 'forms/loginform.phtml'))));
	}
}